<template>
	<view class="wrap">
		<view class="tHeader">
			<g-header title="选择商品" hideRight></g-header>
			<view class="search">
				<view class="search-L">
					<u-search placeholder="搜索店内商品" v-model="keyword" height="60" :show-action="false"
						search-icon-color="#b3b3b3" placeholder-color="#b3b3b3" @search="onSearchConfirm"></u-search>
				</view>
				<view class="classify" @click="showClassifyFlag = true">
					<text class="app_ellipsis">{{typeName}}</text>
				</view>
			</view>
		</view>
		<view class="list">
			<view class="item" v-for="(item, index) in list" :key="index" @click="onGoodsItemTap(index)">
				<view class="item-img">
					<image :src="item.cover" mode=""></image>
				</view>
				<view class="item-main">
					<view class="item-title">{{item.productName}}</view>
					<view class="item-mainB">
						<view class="item-mainB_L">
							<text>￥{{item.price}}/{{item.unit}}</text>
							<text>（{{item.emptyDiff}}）</text>
						</view>
						<view class="item-mainB_R">货号：{{item.id}}</view>
					</view>
				</view>
			</view>
			<no-data v-if="hasLoad && list.length === 0"></no-data>
			<no-more v-if="noMore && list.length > 0"></no-more>
		</view>
		<p-chooseGoods-submitbar v-if="pageType !== 'hotStyle'" :amount="totalPrice"></p-chooseGoods-submitbar>
		<!-- 分类选择 -->
		<u-popup v-model="showClassifyFlag" mode="top">
			<view class="classifyPop">
				<scroll-view class="classifyPop-L" scroll-y="true">
					<view class="classifyPop-Litem" :class="{active: item.active}" v-for="(item, index) in typeList"
						:key="index" @click="onTypeTap(index)">
						{{item.typeTitle}}
					</view>
				</scroll-view>
				<scroll-view class="classifyPop-R" scroll-y="true">
					<view class="classifyPop-Ritem" :class="{active: item.active}"
						v-for="(item, index) in typeListChildren" :key="index" @click="onTypeChildrenTap(index)">
						<text>{{item.typeTitle}}</text>
					</view>
				</scroll-view>
			</view>
		</u-popup>
		<!-- 选择规格（色号） -->
		<u-popup v-model="showOptFlag" mode="bottom" z-index="10088" border-radius="10">
			<view class="optPop">
				<view class="optPop-close">
					<icon type="clear" color="#e1e1e1" size="18" @click="showOptFlag = false"></icon>
				</view>
				<view class="optPop-goods">
					<view class="optPop-img">
						<image :src="sizeCover" mode=""></image>
					</view>
					<view class="optPop-main">
						<view class="optPop-title app_ellipsis">{{tempGoodsInfo.productName}}</view>
						<view class="optPop-mainB">
							<view class="optPop-mainB_L">
								<text v-if="buyType == 1">￥{{tempGoodsInfo.salePrice}}/{{tempGoodsInfo.unit}}</text>
								<text v-if="buyType == 2">￥{{tempGoodsInfo.jyPrice}}/{{tempGoodsInfo.unit}}</text>
								<text>（{{tempGoodsInfo.emptyDiff}}）</text>
							</view>
							<view class="optPop-mainB_R">货号：{{tempGoodsInfo.id}}</view>
						</view>
					</view>
				</view>
				<view class="optPop-search">
					<u-search placeholder="输入色号、颜色关键词搜索" v-model="keyword" height="60" :show-action="false"
						search-icon-color="#b3b3b3" placeholder-color="#b3b3b3"></u-search>
				</view>
				<view class="optPop-sHeader">
					<view class="optPop-sHeader_L">色号选择</view>
				</view>
				<scroll-view v-if="val.name == '大货'" scroll-y="true" class="optPop-list"
					v-for="(val, idx) in tempGoodsInfo.skuList" :key="idx">
					<view class="optPop-item" :class="{active: item.active}" v-for="(item, index) in tempColorList"
						:key="index" @click="onColorItemTap(index)">
						<view class="optPop-item_img">
							<image :src="item.colorUrl" mode=""></image>
						</view>
						<view class="optPop-item_text">{{item.colorCode + item.colorName}}</view>
					</view>
				</scroll-view>
				<view class="optPop-sHeader">
					<view class="optPop-sHeader_L">购买类型</view>
					<view class="optPop-sHeader_R">
						<view class="optPop-sHeader_btn" :class="{active: buyType == 1}" @click="buyType = 1">大货</view>
						<view class="optPop-sHeader_btn" :class="{active: buyType == 2}" @click="buyType = 2">剪样</view>
					</view>
				</view>
				<view class="optPop-btn">
					<g-btn title="确认数量" @click="onOptPopConfirm"></g-btn>
				</view>
			</view>
		</u-popup>
		<!-- 确定数量（剪样） -->
		<u-popup v-model="showCountJYflag" mode="bottom" z-index="10088" border-radius="10">
			<view class="countJYPop">
				<view class="countJYPop-close">
					<icon type="clear" color="#e1e1e1" size="18" @click="showCountJYflag = false"></icon>
				</view>
				<view class="countJYPop-header">确定数量</view>
				<scroll-view class="countJYPop-list">
					<view class="countJYPop-item" v-for="(item, index) in activeColorList" :key="index">
						<view class="countJYPop-img">
							<image :src="item.colorUrl" mode=""></image>
						</view>
						<view class="countJYPop-main">
							<view class="countJYPop-title app_ellipsis">{{item.colorName}}</view>
							<view class="countJYPop-mainM">
								<text>￥</text>
								<text>{{item.jyPrice}}</text>
								<text>/{{tempGoodsInfo.unit}}</text>
								<text>({{tempGoodsInfo.emptyDiff}})</text>
								<text>库存：999</text>
							</view>
							<view class="countJYPop-tips">起售量必须≥{{tempGoodsInfo.startNum}}{{tempGoodsInfo.unit}}</view>
						</view>
						<view class="countJYPop-R">
							<u-number-box v-model="item.count" input-height="54" input-width="60"></u-number-box>
							<view class="countJYPop-mdPrice app_arrow" @click="showMDYPrice(index)">修改单价</view>
						</view>
					</view>
				</scroll-view>
				<view class="countJYPop-total">
					<text>共{{activeColorList.length}}种 共{{jyTotalCount}}{{tempGoodsInfo.unit}}</text>
					<text> 小计：</text>
					<text>￥</text>
					<text>{{jyTotalPrice}}</text>
					<!-- <text>.00</text> -->
				</view>
				<view class="countJYPop-btn">
					<g-btn title="确认添加" @click="onConfirmTap"></g-btn>
				</view>
			</view>
		</u-popup>
		<!-- 确定数量（大货） -->
		<u-popup v-model="showCountDHflag" mode="bottom" z-index="10088" border-radius="10">
			<view class="countDHPop">
				<view class="countDHPop-close">
					<icon type="clear" color="#e1e1e1" size="18" @click="showCountDHflag = false"></icon>
				</view>
				<view class="countDHPop-header">确定数量</view>
				<scroll-view class="countDHPop-list">
					<view class="countDHPop-item app_arrow" @click="onSkipTap('editDHDetailNum', index)"
						v-for="(item, index) in activeColorList" :key="index">
						<view class="countDHPop-img">
							<image :src="item.colorUrl"></image>
						</view>
						<view class="countDHPop-main">
							<view class="countDHPop-title app_ellipsis">{{item.colorName}}</view>
							<view class="countDHPop-mainM">
								<text>￥</text>
								<text>{{item.price}}</text>
								<text>/{{tempGoodsInfo.unit}}</text>
								<text>({{tempGoodsInfo.emptyDiff}})</text>
								<text>库存：999</text>
							</view>
							<view class="countDHPop-tips">起售量必须≥{{tempGoodsInfo.startNum}}{{tempGoodsInfo.unit}}</view>
						</view>
						<view class="countDHPop-R" v-if="item.dhCountArr.length > 0">
							<view class="countDHPop-R_text">共{{calcDHItemCount(item.dhCountArr)}}{{tempGoodsInfo.unit}}
							</view>
							<view class="countDHPop-R_text">共{{item.dhCountArr.length}}条</view>
						</view>
					</view>
				</scroll-view>
				<view class="countDHPop-total">
					<text>共{{activeColorList.length}}种 共{{calcDHItemTotalCount()}}{{tempGoodsInfo.unit}}
						共{{calcDHItemTotalNum()}}条</text>
					<text> 小计：</text>
					<text>￥</text>
					<text>{{calcDHItemtotalPrice()}}</text>
					<!-- <text>.00</text> -->
				</view>
				<view class="countDHPop-btn">
					<g-btn title="确认添加" @click="onConfirmTap"></g-btn>
				</view>
			</view>
		</u-popup>
		<!-- 修改单价 -->
		<u-popup v-model="showMDYPriceflag" mode="center" z-index="10099" border-radius="10">
			<view class="mdyPricePop">
				<view class="mdyPricePop-header">修改单价</view>
				<view class="mdyPricePop-main">
					<view class="mdyPricePop-input">
						<input v-model="tempJyPrice" type="number" placeholder="请输入价格" placeholder-class="phcClass">
					</view>
					<view class="mdyPricePop-tips">
						<text>注：</text>
						<text>修改单价只在当前订单生效，不会改变商品正常售价。</text>
					</view>
				</view>
				<view class="mdyPricePop-footer">
					<view class="mdyPricePop-btn" @click="showMDYPriceflag = false">取消</view>
					<view class="mdyPricePop-btn" @click="changeJYPrice">确定</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageType: 'normal', // 默认为可选择商品规格？
				showClassifyFlag: false,
				showOptFlag: false,
				showCountJYflag: false,
				showCountDHflag: false,
				showMDYPriceflag: false,
				buyType: 1, // 弹窗 购买类型 1大货  2剪样
				typeList: [],
				typeListChildren: [],
				typeName: '全部分类',
				keyword: '',
				list: [],
				page: 1,
				size: 15,
				colorPage: 1,
				colorSize: 20,
				hasLoad: false,
				noMore: false,
				tempGoodsInfo: {},
				tempColorList: [],
				// activeColorList: [],
				jYMDYIndex: 0,
				tempJyPrice: 0
			}
		},
		computed: {
			sizeCover() {
				if (!this.tempGoodsInfo?.skuList || this.tempGoodsInfo.skuList.length === 0) {
					return this.$g_util.concatRequestUrl(this.tempGoodsInfo.showImages)
				} else if (this.buyType == 2) {
					return this.$g_util.concatRequestUrl(this.tempGoodsInfo.skuList?.find(item => item.name == '剪样').image)
				} else {
					return this.$g_util.concatRequestUrl(this.tempGoodsInfo.skuList?.find(item => item.name == '大货').image)
				}
			},
			activeColorList() {
				let list = this.tempColorList?.filter(item => item.active) || []
				// 大货可以单独配置价格（根据色号里的价格来）
				// 剪样统一价格（商品详情里的剪样价格）
				// if (this.buyType == 1) { // 大货
				// 	list.forEach(item => {
				// 		item.showPrice = item.price
				// 	})
				// } else { // 剪样
				// 	list.forEach(item => {
				// 		item.showPrice = this.tempGoodsInfo.jyPrice
				// 	})
				// }
				return list
			},
			jyTotalPrice() {
				return this.activeColorList.reduce((total, item) => {
					return total / 1 + item.count * item.jyPrice
				}, 0)
			},
			jyTotalCount() {
				return this.activeColorList.reduce((total, item) => {
					return total / 1 + item.count
				}, 0)
			},
			dhTotalPrice() {
				return this.activeColorList.reduce((total, item) => {
					return total / 1 + item.count * item.price
				}, 0)
			},
			totalPrice() {
				const price = this.gSalesTicketGoodsList.reduce((total, item) => {
					return total / 1 + item.colorList.reduce((t, v) => {
						if (item.goodsType == 'dh') {
							return t / 1 + v.totalCount * v.price
						} else if (item.goodsType == 'jy') {
							return t / 1 + v.count * v.jyPrice
						} else {
							return t
						}
					}, 0)
				}, 0)
				return price.toFixed(1)
			},
		},
		onLoad(options) {
			this.setPageType(options.pageType)
			this.$store.dispatch('updateShopInfo')
			this.productTypeId = options.productTypeId || ''
			this.keyword = options.keyword || ''
			this.updatePage()
		},
		onUnload() {
			uni.$off('update-dhInfo', this.updateDHInfo)
		},
		onPullDownRefresh() {
			// this.updatePage()
		},
		onReachBottom() {
			this.page++
			this.getList()
		},
		methods: {
			async updatePage() {
				try {
					this.resetPage()
					let typeList = await this.getProductTypeList()
					let typeListChildren = await this.getProductTypeChildren(typeList[0].id)
					// this.productTypeId = typeListChildren[0]?.id || 0
					this.getList()
				} catch (e) {
					//TODO handle the exception
				}
			},
			resetPage() {
				this.list = []
				this.page = 1
				this.size = 15
				this.hasLoad = false
				this.noMore = false
			},
			setPageType(pageType) {
				this.pageType = pageType || 'normal'
			},
			onSkipTap(type, index) {
				const urlObj = {
					shopCartSelect: '/pages/commodityManagement/shopCartSelect',
					editDHDetailNum: () => {
						uni.$off('update-dhInfo', this.updateDHInfo)
						uni.$on('update-dhInfo', this.updateDHInfo)
						console.log(index);
						const dh = {
							index,
							colorId: this.activeColorList[index].colorId,
							dhCountArr: this.activeColorList[index].dhCountArr,
							customEmptyDiff: this.activeColorList[index].customEmptyDiff,
							customEmptyDiffUnit: this.activeColorList[index].customEmptyDiffUnit,
							cover: this.tempGoodsInfo.cover,
							productName: this.tempGoodsInfo.productName,
							price: this.activeColorList[index].price,
							startNum: this.tempGoodsInfo.startNum,
							unit: this.tempGoodsInfo.unit,
							emptyDiff: this.tempGoodsInfo.emptyDiff,
						}
						uni.navigateTo({
							url: `/pages/commodityManagement/editDHDetailNum?dh=${JSON.stringify(dh)}`
						})
					}
				}
				this.$g_util.navigationTo(urlObj, type)
			},
			updateDHInfo(dh = {}) {
				console.log(dh);
				this.tempColorList = this.tempColorList.map((item, index) => {
					if (item.colorId == dh.colorId) {
						item.dhCountArr = dh.dhCountArr
						item.price = dh.price
						item.customEmptyDiff = dh.customEmptyDiff
						item.customEmptyDiffUnit = dh.customEmptyDiffUnit
					}
					return item
				})
			},
			async onGoodsItemTap(index) {
				if (this.pageType === 'hotStyle') {
					uni.$emit('update-hotstyleEditGoodsList', this.list[index])
					uni.navigateBack()
					return
				}
				try {
					uni.showLoading({
						title: '加载中'
					})
					await Promise.all([this.getProductColor(this.list[index].id, ''), this.getProductInfo(this.list[
						index].id)])
					this.tempColorList = this.tempColorList.map((item, index) => {
						item.jyPrice = this.tempGoodsInfo.jyPrice
						return item
					})
					this.showOptFlag = true
				} catch (e) {
					uni.showToast({
						title: e,
						icon: 'none'
					})
					//TODO handle the exception
				} finally {
					uni.hideLoading()
				}

			},
			/**
			 * 规格弹窗 确认数量按钮
			 */
			onOptPopConfirm() {
				if (!this.tempColorList.find(item => item.active)) {
					uni.showToast({
						title: '至少选择一个色号',
						icon: 'none'
					})
					return
				}
				if (this.buyType == 1) {
					this.showCountDHflag = true
				} else if (this.buyType == 2) {
					this.showCountJYflag = true
				}
			},
			onConfirmTap() {
				let shopCartList = JSON.parse(JSON.stringify(this.gSalesTicketGoodsList))
				const tempGoodsInfo = this.tempGoodsInfo
				let goodsInfo = {
					id: tempGoodsInfo.id,
					cover: this.sizeCover,
					productName: tempGoodsInfo.productName,
					startNum: tempGoodsInfo.startNum,
					unit: tempGoodsInfo.unit,
					emptyDiff: tempGoodsInfo.emptyDiff,
					salePrice: tempGoodsInfo.salePrice,
					jyPrice: tempGoodsInfo.jyPrice,
					colorList: this.activeColorList
				}
				if (this.buyType == 1) { // 大货
					goodsInfo.goodsType = 'dh'
					if (this.activeColorList.find(item => !item.dhCountArr || item.dhCountArr.length === 0)) {
						uni.showToast({
							title: '请为每个色号添加数量',
							icon: 'none'
						})
						return
					}
					goodsInfo.colorList = this.activeColorList.map((item, index) => {
						item.totalCount = this.calcDHItemCount(item.dhCountArr)
						return item
					})
					this.showCountDHflag = false
				} else if (this.buyType == 2) { // 剪样
					goodsInfo.goodsType = 'jy'
					this.showCountJYflag = false
				}
				shopCartList.push(goodsInfo)
				this.$store.commit('updateSalesTicketGoodsList', shopCartList)
				this.showOptFlag = false
			},
			getProductTypeList() {
				return new Promise((resolve, reject) => {
					this.$g_api.productTypeList().then(({
						data
					}) => {
						if (data?.length > 0) {
							data = data.map((item, index) => {
								item.active = index == 0
								return item
							})
							this.typeList = data
							resolve(data)
						}
					})
				})
			},
			getProductTypeChildren(parentId) {
				return new Promise((resolve, reject) => {
					this.$g_api.productTypeChildren({
						parentId
					}).then(({
						data
					}) => {
						if (data?.length > 0) {
							data = this.$g_util.concatRequestUrl(data, 'icon')
							data = data.map((item, index) => {
								item.active = index == 0
								if(item.id == this.productTypeId) {
									this.typeName = item.typeTitle
								}
								return item
							})
							this.typeListChildren = data
							resolve(data)
						}
					})
				})
			},
			onTypeTap(index) {
				const typeList = this.typeList
				typeList.forEach((item, idx) => {
					item.active = index == idx
				})
				this.getProductTypeChildren(typeList[index].id)
			},
			onTypeChildrenTap(index) {
				const typeListChildren = this.typeListChildren
				typeListChildren.forEach((item, idx) => {
					item.active = index == idx
				})
				this.productTypeId = typeListChildren[index].id
				this.typeName = typeListChildren[index].typeTitle
				this.resetPage()
				this.getList()
				this.showClassifyFlag = false
			},
			onSearchConfirm() {
				this.updatePage()
			},
			getList() {
				this.$g_api.productSearchProducts({
					productName: this.keyword,
					pageNum: this.page,
					pageSize: this.size,
					storeId: this.gShopInfo.id,
					productTypeId: this.productTypeId
				}).then(({
					rows
				}) => {
					console.log(rows);
					uni.stopPullDownRefresh()
					this.hasLoad = true
					if (rows?.length > 0) {
						rows = this.$g_util.concatRequestUrl(rows, 'cover')
						this.list = this.list.concat(rows)
					} else {
						this.noMore = true
					}
				})
			},
			async getProductInfo(productId) {
				try {
					const {
						data
					} = await this.$g_api.productDetailProduct({
						productId
					})
					data.cover = this.$g_util.concatRequestUrl(data.cover)
					if (!data.skuList || data.skuList.length === 0)
						return Promise.reject('该商品暂未配置规格，无法选择')
					data.skuList.forEach(item => {
						item.skuColorList.forEach(val => {
							val.colorUrl = this.$g_util.concatRequestUrl(val.colorUrl)
						})
					})
					this.tempGoodsInfo = data
					return Promise.resolve()
				} catch (e) {
					//TODO handle the exception
					return Promise.reject(e)
				}
			},
			async getProductColor(productId, keyword = '') {
				try {
					let {
						data
					} = await this.$g_api.productProductColors({
						productId,
						colorCode: keyword,
						pageNum: this.colorPage,
						pageSize: this.colorSize
					})
					data = this.$g_util.concatRequestUrl(data, 'colorUrl')
					data.forEach(item => {
						item.count = 1
						item.active = false
						item.dhCountArr = []
					})
					this.tempColorList = data || []
				} catch (e) {
					//TODO handle the exception
					console.log(e);
				}
			},
			onColorItemTap(index) {
				this.tempColorList.forEach((item, idx) => {
					if (index == idx) {
						item.active = !item.active
					}
				})
			},
			showMDYPrice(index) {
				this.jYMDYIndex = index
				this.showMDYPriceflag = true
			},
			changeJYPrice() {
				this.$set(this.tempColorList, this.jYMDYIndex, {
					...this.tempColorList[this.jYMDYIndex],
					jyPrice: this.tempJyPrice
				})
				// this.tempColorList.forEach((item, index) => {
				// 	if(index == this.jYMDYIndex) {
				// 		item.jyPrice = this.tempJyPrice
				// 	}
				// })
				this.showMDYPriceflag = false
			},
			calcDHItemCount(dh = []) {
				let num = dh.reduce((total, item) => {
					return total / 1 + item / 1
				}, 0)
				return num.toFixed(1)
			},
			calcDHItemTotalCount() {
				if (this.activeColorList?.length > 0) {
					let num = this.activeColorList.reduce((total, item) => {
						let count = 0
						if (item.dhCountArr?.length > 0) {
							count = item.dhCountArr.reduce((t, v) => {
								return t / 1 + v / 1
							}, 0)
						}
						console.log(count);
						return total / 1 + count / 1
					}, 0)
					return num.toFixed(1)
				} else {
					return 0
				}
			},
			calcDHItemTotalNum() {
				if (this.activeColorList?.length > 0) {
					let num = this.activeColorList.reduce((total, item) => {
						let count = 0
						if (item.dhCountArr?.length > 0) {
							count = item.dhCountArr.length
						}
						return total / 1 + count / 1
					}, 0)
					return num.toFixed(1)
				} else {
					return 0
				}
			},
			calcDHItemtotalPrice() {
				if (this.activeColorList?.length > 0) {
					let price = this.activeColorList.reduce((total, item) => {
						let count = 0
						if (item.dhCountArr?.length > 0) {
							count = item.dhCountArr.reduce((t, v) => {
								return t / 1 + v * item.price
							}, 0)
						}
						return total / 1 + count / 1
					}, 0)
					return price.toFixed(1)
				} else {
					return 0
				}
			},
		}
	}
</script>
<style>
	::-webkit-scrollbar {
		width: 0;
		height: 0;
		color: transparent;
	}
</style>
<style scoped lang="scss">
	::v-deep .u-numberbox {
		border: 1px solid #e6e6e6;
		border-radius: 6rpx;
	}

	::v-deep .u-number-input {
		min-width: 82rpx !important;
		margin: 0 !important;
		background-color: #fff !important;
	}

	.wrap {
		padding-top: calc(var(--status-bar-height) + 98rpx + 60rpx + 20rpx);
	}

	.tHeader {
		position: fixed;
		top: 0;
		left: 0;
		background-color: #fff;
		padding-bottom: 20rpx;
		border-bottom: 1px solid $g-border-color;
		z-index: 10086;
	}

	.search {
		display: flex;
		align-items: center;
		padding: 0 30rpx;
	}

	.search-L {
		flex: 1;
		min-width: 300rpx;
	}

	.classify {
		display: flex;
		justify-content: center;
		min-width: 190rpx;
		max-width: 250rpx;
		padding-left: 10rpx;
		box-sizing: border-box;

		text {
			position: relative;
			max-width: 250rpx;

			&::after {
				content: '';
				width: 12rpx;
				height: 12rpx;
				position: absolute;
				right: -30rpx;
				top: 50%;
				border-top: 1px solid #888;
				border-right: 1px solid #888;
				transform: translateY(-50%) rotate(135deg);
			}
		}
	}

	.list {
		padding-bottom: calc(100rpx + constant(safe-area-inset-bottom));
		padding-bottom: calc(100rpx + env(safe-area-inset-bottom));
	}

	.item {
		display: flex;
		padding: 30rpx;
		border-bottom: 1px solid $g-border-color;
		background-color: #fff;
	}

	.item-img {
		width: 140rpx;
		font-size: 0;

		image {
			width: 140rpx;
			height: 140rpx;
			border-radius: 10rpx;
			background-color: $g-main-bg;
		}
	}

	.item-main {
		flex: 1;
		margin-left: 30rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.item-title {
		font-size: 28rpx;
		font-weight: bold;
	}

	.item-mainB {
		display: flex;
		justify-content: space-between;
	}

	.item-mainB_L {
		text {
			&:first-child {
				color: #FF4C4C;
				font-size: 26rpx;
			}

			&:last-child {
				color: #999999;
				font-size: 20rpx;
			}
		}
	}

	.item-mainB_R {
		font-size: 24rpx;
		color: #999;
	}

	.classifyPop {
		display: flex;
		padding-top: calc(var(--status-bar-height) + 98rpx + 60rpx + 20rpx);
	}

	.classifyPop-L {
		width: 200rpx;
		max-height: 60vh;
		background-color: $g-main-bg;
	}

	.classifyPop-Litem {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 200rpx;
		height: 80rpx;

		&.active {
			background-color: #fff;
		}
	}

	.classifyPop-R {
		width: 550rpx;
		max-height: 60vh;
		padding: 0 30rpx;
	}

	.classifyPop-Ritem {
		display: flex;
		align-items: center;
		height: 80rpx;

		&.active {
			position: relative;
			color: $g-main-color;

			&::after {
				content: '';
				position: absolute;
				right: 2rpx;
				top: 50%;
				width: 26rpx;
				height: 14rpx;
				border-left: 2px solid $g-main-color;
				border-bottom: 2px solid $g-main-color;
				transform: translateY(-60%) rotate(-45deg);
			}
		}
	}

	.optPop {
		position: relative;
		padding-bottom: calc(constant(safe-area-inset-bottom) + 30rpx);
		padding-bottom: calc(env(safe-area-inset-bottom) + 30rpx);
	}

	.optPop-close {
		position: absolute;
		right: 20rpx;
		top: 30rpx;
	}

	.optPop-goods {
		display: flex;
		padding: 30rpx;
		background-color: #fff;
	}

	.optPop-img {
		width: 140rpx;
		font-size: 0;

		image {
			width: 140rpx;
			height: 140rpx;
			border-radius: 10rpx;
			background-color: $g-main-bg;
		}
	}

	.optPop-main {
		flex: 1;
		margin-left: 30rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.optPop-title {
		max-width: 480rpx;
		font-size: 28rpx;
		font-weight: bold;
	}

	.optPop-mainB {
		display: flex;
		justify-content: space-between;
	}

	.optPop-mainB_L {
		text {
			&:first-child {
				color: #FF4C4C;
				font-size: 26rpx;
			}

			&:last-child {
				color: #999999;
				font-size: 20rpx;
			}
		}
	}

	.optPop-mainB_R {
		font-size: 24rpx;
		color: #999;
	}

	.optPop-search {
		padding: 0 30rpx;
	}

	.optPop-sHeader {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 30rpx;
		height: 60rpx;
		margin: 18rpx 0;
	}

	.optPop-sHeader_L {}

	.optPop-sHeader_R {
		display: flex;
	}

	.optPop-sHeader_btn {
		margin-left: 20rpx;
		width: 120rpx;
		// height: 60rpx;
		line-height: 60rpx;
		text-align: center;
		font-size: 24rpx;
		color: #333;
		background: #F2F2F2;
		border-radius: 30rpx;

		&.active {
			color: $g-main-color;
			border: 1px solid $g-main-color;
			background-color: #fff;
		}
	}

	.optPop-list {
		padding-left: 34rpx;
		max-height: 50vh;
		margin-bottom: 30rpx;
		border-bottom: 1px solid $g-border-color;
	}

	.optPop-item {
		display: inline-block;
		margin-right: 32rpx;
		border-radius: 10rpx;
		margin-bottom: 20rpx;
		border: 1px solid transparent;
		background-color: $g-main-bg;
		overflow: hidden;

		&:nth-child(4n) {
			margin-right: 0;
		}

		&.active {
			background-color: #fff;
			border: 1px solid #FF7733;

			.optPop-item_text {
				color: #FF7733;
			}
		}
	}

	.optPop-item_img {
		width: 146rpx;
		font-size: 0;

		image {
			width: 146rpx;
			height: 146rpx;
			// border-radius: 10rpx;
			// background-color: #F8C701;
		}
	}

	.optPop-item_text {
		padding: 8rpx 10rpx;
		color: #333;
		font-size: 20rpx;
		text-align: center;
	}

	.optPop-btn {
		margin-top: 40rpx;
	}

	.countJYPop {
		position: relative;
		padding-bottom: calc(constant(safe-area-inset-bottom) + 30rpx);
		padding-bottom: calc(env(safe-area-inset-bottom) + 30rpx);
	}

	.countJYPop-close {
		position: absolute;
		right: 20rpx;
		top: 30rpx;
	}

	.countJYPop-header {
		height: 90rpx;
		line-height: 90rpx;
		text-align: center;
		font-size: 32rpx;
	}

	.countJYPop-list {
		padding: 30rpx 30rpx 0;
	}

	.countJYPop-item {
		display: flex;
		margin-bottom: 30rpx;
	}

	.countJYPop-img {
		width: 120rpx;
		flex-shrink: 0;
		margin-right: 20rpx;

		image {
			width: 120rpx;
			height: 120rpx;
			border-radius: 10rpx;
			background-color: $g-main-bg;
		}
	}

	.countJYPop-main {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		max-width: 340rpx;
	}

	.countJYPop-title {
		// max-width: 340rpx;
	}

	.countJYPop-mainM {
		text {
			&:first-child {
				font-size: 20rpx;
				color: #ff4c4c;
			}

			&:nth-child(2) {
				font-size: 28rpx;
				color: #ff4c4c;
			}

			&:nth-child(3) {
				font-size: 20rpx;
				color: #ff4c4c;
			}

			&:nth-child(4) {
				font-size: 20rpx;
				color: #999;
			}

			&:nth-child(5) {
				margin-left: 20rpx;
				font-size: 24rpx;
				color: #999;
			}
		}
	}

	.countJYPop-tips {
		font-size: 24rpx;
		color: #999;
	}

	.countJYPop-R {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-end;
		margin-left: 20rpx;
		flex-shrink: 0;
		max-width: 190rpx;
	}

	.countJYPop-mdPrice {
		padding-right: 26rpx;

		&::after {
			right: 10rpx;
		}
	}

	.countJYPop-total {
		text-align: right;
		padding-right: 30rpx;

		text {
			font-size: 26rpx;
			color: #999;

			&:nth-child(2) {
				margin-left: 10rpx;
				color: #333;
			}

			&:nth-child(3) {
				font-size: 20rpx;
				color: #FF4C4C;
			}

			&:nth-child(4) {
				color: #FF4C4C;
			}

			&:nth-child(5) {
				font-size: 20rpx;
				color: #FF4C4C;
			}
		}
	}

	.countJYPop-btn {
		margin-top: 50rpx;
	}

	.countDHPop {
		position: relative;
		padding-bottom: calc(constant(safe-area-inset-bottom) + 30rpx);
		padding-bottom: calc(env(safe-area-inset-bottom) + 30rpx);
	}

	.countDHPop-close {
		position: absolute;
		right: 20rpx;
		top: 30rpx;
	}

	.countDHPop-header {
		height: 90rpx;
		line-height: 90rpx;
		text-align: center;
		font-size: 32rpx;
	}

	.countDHPop-list {
		padding: 30rpx 30rpx 0;
		box-sizing: border-box;
	}

	.countDHPop-item {
		display: flex;
		margin-bottom: 30rpx;

		&.app_arrow {
			&::after {
				right: 10rpx;
				width: 14rpx;
				height: 14rpx;
			}
		}
	}

	.countDHPop-img {
		width: 120rpx;
		flex-shrink: 0;
		margin-right: 20rpx;

		image {
			width: 120rpx;
			height: 120rpx;
			border-radius: 10rpx;
			background-color: $g-main-bg;
		}
	}

	.countDHPop-main {
		flex: 1;
		flex-shrink: 0;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		// max-width: 380rpx;
	}

	.countDHPop-title {
		// max-width: 340rpx;
	}

	.countDHPop-mainM {
		text {
			&:first-child {
				font-size: 20rpx;
				color: #ff4c4c;
			}

			&:nth-child(2) {
				font-size: 28rpx;
				color: #ff4c4c;
			}

			&:nth-child(3) {
				font-size: 20rpx;
				color: #ff4c4c;
			}

			&:nth-child(4) {
				font-size: 20rpx;
				color: #999;
			}

			&:nth-child(5) {
				margin-left: 20rpx;
				font-size: 24rpx;
				color: #999;
			}
		}
	}

	.countDHPop-tips {
		font-size: 24rpx;
		color: #999;
	}

	.countDHPop-R {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: flex-end;
		margin-left: 20rpx;
		flex-shrink: 0;
		max-width: 190rpx;
	}

	.countDHPop-R_text {
		font-size: 24rpx;
		color: #999;
	}

	.countDHPop-mdPrice {
		padding-right: 26rpx;

		&::after {
			right: 10rpx;
		}
	}

	.countDHPop-total {
		text-align: right;
		padding-right: 30rpx;

		text {
			font-size: 26rpx;
			color: #999;

			&:nth-child(2) {
				margin-left: 10rpx;
				color: #333;
			}

			&:nth-child(3) {
				font-size: 20rpx;
				color: #FF4C4C;
			}

			&:nth-child(4) {
				color: #FF4C4C;
			}

			&:nth-child(5) {
				font-size: 20rpx;
				color: #FF4C4C;
			}
		}
	}

	.countDHPop-btn {
		margin-top: 50rpx;
	}

	.mdyPricePop {
		width: 600rpx;
	}

	.mdyPricePop-header {
		line-height: 100rpx;
		font-size: 36rpx;
		color: #333;
		text-align: center;
	}

	.mdyPricePop-main {
		padding: 0 50rpx 60rpx;
	}

	.mdyPricePop-input {
		margin: 10rpx 0 30rpx;

		input {
			border: 1px solid #e6e6e6;
			height: 90rpx;
			border-radius: 10rpx;
			padding: 0 30rpx;
		}

		::v-deep .phcClass {
			color: #ccc;
		}
	}

	.mdyPricePop-tips {
		font-size: 24rpx;
		color: #999;
		display: flex;

		text {
			display: block;
		}
	}

	.mdyPricePop-footer {
		display: flex;
		border-top: 1px solid $g-border-color;
	}

	.mdyPricePop-btn {
		flex: 1;
		line-height: 100rpx;
		text-align: center;

		&:first-child {
			position: relative;
			font-size: 32rpx;

			&::after {
				position: absolute;
				right: 0;
				top: 50%;
				content: '';
				width: 2rpx;
				height: 60rpx;
				transform: translateY(-50%);
				border-radius: 2rpx;
				background-color: $g-main-bg;
			}
		}

		&:last-child {
			font-size: 32rpx;
			color: $g-main-color;
		}
	}
</style>